package edu.polsl.bio.str.manager.dao;

import edu.polsl.bio.str.common.entity.ChromInfo;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * //todo class description
 * <p/>
 * Created on: Jul 25, 2011 2:27:23 PM <br/>
 * <a href="http://www.polsl.pl">www.polsl.pl</a>
 *
 * @author lukasz.olczak@polsl.pl
 */
public class ChromInfoDaoImpl extends BaseDao implements ChromInfoDao {
  /**
   * slf4j Logger.
   */
  private static final Logger log = LoggerFactory.getLogger(ChromInfoDaoImpl.class.getName());

  @Override
  public int getSizeFor(Long individualId, Long chromId) {
    DetachedCriteria query = DetachedCriteria.forClass(ChromInfo.class)
        .add(Restrictions.and(Restrictions.eq("chromosomeId", chromId.intValue()), Restrictions.eq("individualId", individualId.intValue())));
    ChromInfo chromInfo = getUniqueResult(getHibernateTemplate().findByCriteria(query));
    return chromInfo.getSize();
  }
}
